$(function() {
    function g(U) {
        if (false && window.addEventListener) {
            U.addEventListener("touchstart", h, false);
            U.addEventListener("touchmove", y, false);
            U.addEventListener("touchend", I, false)
        } else {
            if (false && window.attachEvent) {
                U.attachEvent("touchstart", h);
                U.attachEvent("touchmove", y);
                U.attachEvent("touchend", I)
            } else {
                U.ontouchstart = h;
                U.ontouchmove = y;
                U.ontouchend = I
            }
        }
    }
    var F = createSpinner();
    var j = createSpinner();
    function B(U, Z) {
        var aa = u();
        if (aa == "") {
            return
        }
        var V = aa.split(",");
        if (V.length == 0) {
            return
        }
        if (Z == undefined) {
            var X = '<span class="tbl-cell"><img src="' + U.src + '" seq="' + k + '" width="310" height="310"></span>';
            $("#imgSlider").html(X);
            var X = "";
            for (var W = 0; W < V.length; W++) {
                X = X + '<li class="new-tbl-cell ' + (W == 0 ? "on": "") + '"><a href="javascript:void(0)"></a></li>'
            }
            if (X != "") {
                $("#imgSliderPage").show();
                $("#imgSliderPage").html(X)
            } else {
                $("#imgSliderPage").hide()
            }
            $("#imgSlider").css("margin-left", "0px");
            var X = '<li class="new-tbl-cell"><a href="javascript:void(0)"><span class="new-shade-img"><img src="' + U.src + '" seq="' + k + '" alt="" width="310" height="310"></span></a></li>';
            $("#bigImgSlider").html(X);
            var X = "";
            for (var W = 0; W < V.length; W++) {
                X = X + '<li class="new-tbl-cell ' + (W == 0 ? "on": "") + '"><a href="javascript:void(0)"></a></li>'
            }
            if (X != "") {
                $("#bigImgSliderPage").html(X);
                $("#bigImgSliderPage").show()
            } else {
                $("#bigImgSliderPage").hide()
            }
            $("#bigImgSlider").css("margin-left", "0px")
        } else {
            if (Z == 1) {
                if (V.length == 1) {
                    return
                }
                var Y = k - 1 < 0 ? V.length - 1: k - 1;
                $('#imgSlider img[seq="' + Y + '"]').parent("span").siblings().remove();
                var X = '<span class="tbl-cell"><img src="' + G[k].src + '" seq="' + k + '" width="310" height="310"></span>';
                $("#imgSlider").append(X);
                $("#imgSlider").css("left", "0px");
                setTimeout(function() {
                    $("#imgSlider").animate({
                        left: "-310px"
                    },
                    200)
                },
                10);
                $("#imgSliderPage").children("li").removeClass("on");
                $("#imgSliderPage").children("li").eq(k).addClass("on");
                $("#imgSliderPage").show();
                $('#bigImgSlider img[seq="' + Y + '"]').parent("span").parent("a").parent("li").siblings().remove();
                var X = '<li class="new-tbl-cell"><a href="javascript:void(0)"><span class="new-shade-img"><img src="' + G[k].src + '" seq="' + k + '" width="310" height="310"></span></a></li>';
                $("#bigImgSlider").append(X);
                $("#bigImgSlider").css("margin-left", "0px");
                setTimeout(function() {
                    $("#bigImgSlider").animate({
                        "margin-left": "-310px"
                    },
                    200)
                },
                10);
                $("#bigImgSliderPage").children("li").removeClass("on");
                $("#bigImgSliderPage").children("li").eq(k).addClass("on");
                $("#bigImgSliderPage").show()
            } else {
                if (Z == 0) {
                    if (V.length == 1) {
                        return
                    }
                    var Y = k + 1 > V.length - 1 ? 0: k + 1;
                    $('#imgSlider img[seq="' + Y + '"]').parent("span").siblings().remove();
                    var X = '<span class="tbl-cell"><img src="' + G[k].src + '" seq="' + k + '" width="310" height="310"></span>';
                    $("#imgSlider").prepend(X);
                    $("#imgSlider").css("left", "-310px");
                    setTimeout(function() {
                        $("#imgSlider").animate({
                            left: "0px"
                        },
                        200)
                    },
                    10);
                    $("#imgSliderPage").children("li").removeClass("on");
                    $("#imgSliderPage").children("li").eq(k).addClass("on");
                    $("#imgSliderPage").show();
                    $('#bigImgSlider img[seq="' + Y + '"]').parent("span").parent("a").parent("li").siblings().remove();
                    var X = '<li class="new-tbl-cell"><a href="javascript:void(0)"><span class="new-shade-img"><img src="' + G[k].src + '" seq="' + k + '" width="310" height="310"></span></a></li>';
                    $("#bigImgSlider").prepend(X);
                    $("#bigImgSlider").css("margin-left", "-310px");
                    setTimeout(function() {
                        $("#bigImgSlider").animate({
                            "margin-left": "0px"
                        },
                        200)
                    },
                    10);
                    $("#bigImgSliderPage").children("li").removeClass("on");
                    $("#bigImgSliderPage").children("li").eq(k).addClass("on");
                    $("#bigImgSliderPage").show()
                }
            }
        }
        if (U) {}
    }
    function p(U) {
        if (U && U.ware && U.ware.images && U.ware.images.length > 0) {
            var V = "";
            $.each(U.ware.images, 
            function(X, W) {
                if (W && W.newpath) {
                    V = V + W.newpath.replace("/n4/", "/n1/") + ","
                }
            });
            $("#imgs").val(V);
            G = new Array(u().split(",").length);
            k = 0;
            E();
            B(G[k])
        }
    }
    
    
    function A(U) {
        if (U && U.ware && U.ware.comNum) {
            if (parseInt(U.ware.comNum) > 0) {
                $("#comments").html("<em>" + U.ware.comNum + "</em> \u4eba\u8bc4\u4ef7  <em>" + U.ware.good + "</em> \u597d\u8bc4")
            } else {
                $("#comments").html("<em>" + U.ware.comNum + "</em> \u4eba\u8bc4\u4ef7  <em> 100%</em> \u597d\u8bc4")
            }
        }
    }
    function D(U) {
        if (U && U.ware && U.ware.orderNum) {
            if (parseInt(U.ware.orderNum) > 0) {
                $("#orderComment").html('<span class="icon"></span>\u5546\u54c1\u6652\u5355(' + U.ware.orderNum + ")")
            } else {
                $("#orderComment").html('<span class="icon"></span>\u5546\u54c1\u6652\u5355')
            }
        }
    }
    function H(U) {
        if (U && U.ware && U.ware.cousultNum) {
            if (parseInt(U.ware.cousultNum) > 0) {
                $("#consultations").html('<span class="icon"></span>\u8d2d\u4e70\u54a8\u8be2(' + U.ware.cousultNum + ")")
            } else {
                $("#consultations").html('<span class="icon"></span>\u8d2d\u4e70\u54a8\u8be2')
            }
        }
    }
    function K(U) {
        $("#spinner1").show();
        j.spin($("#spinner1")[0]);
        $.post("/ware/view.json", {
            wareId: U,
            sid: $("#sid").val(),
            provinceId: $("#province").val(),
            cityId: $("#city").val(),
            countryId: $("#country").val(),
            townId: $("#town").val(),
            teamSign: $("#teamSign").val(),
            feeType: $("#feeType").val()
        },
        function(V) {
            o(V);
            p(V);
            d(V);
            j.stop();
            T(V);
            A(V);
            D(V);
            H(V);
            $("#spinner1").hide();
            window.scrollTo(0, 0)
        },
        "json")
    }
    function n(V, U) {
        $("#spinner1").show();
        j.spin($("#spinner1")[0]);
        $.post("/ware/view.json", {
            provinceId: U,
            cityId: V,
            sid: $("#sid").val(),
            wareId: $("#currentWareId").val(),
            teamSign: $("#teamSign").val()
        },
        function(W) {
            J(W);
            v(W);
            j.stop();
            $("#spinner1").hide()
        },
        "json")
    }
    function i(U) {
        $("#spinner1").show();
        j.spin($("#spinner1")[0]);
        $.post("/ware/view.json", {
            provinceId: U,
            sid: $("#sid").val(),
            wareId: $("#currentWareId").val(),
            teamSign: $("#teamSign").val()
        },
        function(V) {
            J(V);
            v(V);
            j.stop();
            $("#spinner1").hide()
        },
        "json")
    }
    function s(V, U, W) {
        $("#spinner1").show();
        j.spin($("#spinner1")[0]);
        $.post("/ware/view.json", {
            provinceId: U,
            cityId: W,
            countryId: V,
            sid: $("#sid").val(),
            wareId: $("#currentWareId").val(),
            teamSign: $("#teamSign").val()
        },
        function(X) {
            J(X);
            v(X);
            j.stop();
            $("#spinner1").hide()
        },
        "json")
    }
    function C(V, U, X, W) {
        $("#spinner1").show();
        j.spin($("#spinner1")[0]);
        $.post("/ware/view.json", {
            provinceId: U,
            cityId: X,
            countryId: W,
            townId: V,
            sid: $("#sid").val(),
            wareId: $("#currentWareId").val(),
            teamSign: $("#teamSign").val()
        },
        function(Y) {
            J(Y);
            v(Y);
            d(Y);
            j.stop();
            $("#spinner1").hide()
        },
        "json")
    }
    function x() {
        var U = $("#currentWareId").val();
        var V = "http://chat1.jd.com/api/checkChat?pid=" + U + "&entry=m_item&returnCharset=gb2312&callback=?";
        jQuery.getJSON(V, S)
    }
    function S(V) {
        if (!V || !V.code) {
            return
        }
        var W = V.code;
        if (W == 1) {
            $("#kefu").show();
            var U = "http://im.m.jd.com/merchant/index?v=6&sku=" + $("#currentWareId").val() + "&imgUrl=" + $("#imgUrl").val() + "&goodName=" + encodeURIComponent(encodeURIComponent($("#goodName").val())) + "&jdPrice=" + $("#jdPrice").val() + "&sid=" + $("#sid").val();
            $("#im").attr("href", U)
        } else {
            if (W == 2 || W == 3 || W == 9) {
                $("#kefu").show();
                $("#im").addClass("btn-call-def")
            }
        }
    }
    function v(W) {
        if (W && W.ware && W.ware.marketPrice && W.ware.showMartPrice) {
            $("#marketPrice").show();
            $("#marketPrice").empty();
            if (W.marketPrice) {
                $("#marketPrice").html("&yen;" + W.marketPrice)
            } else {
                $("#marketPrice").html("&yen;" + W.ware.marketPrice)
            }
        } else {
            $("#marketPrice").hide()
        }
        if (W.promotionInfo && W.promotionInfo.promotionInfoTitle.length > 0) {
            var U = W.promotionInfo.promotionInfoTitle + W.promotionInfo.promotionInfo;
            $("#promotionInfo").html(U);
            $("#promotionInfo").show()
        } else {
            $("#promotionInfo").hide()
        }
        if (W && W.stock) {
            var V = "";
            if (W.stock.jdPrice && W.stock.jdPrice != "" && W.stock.jdPrice.toLowerCase() != "null" && parseFloat(W.stock.jdPrice) > 0) {
                V = "&yen;" + W.stock.jdPrice
            } else {
                V = "&#26242;&#26080;&#25253;&#20215;"
            }
            $("#price").html(V);
            $("#currentWareId").val(W.stock.wareId)
        } else {
            var V = "";
            if (W.ware.jdPrice && W.ware.jdPrice != "" && W.ware.jdPrice.toLowerCase() != "null" && parseFloat(W.ware.jdPrice) > 0) {
                V = "&yen;" + W.ware.jdPrice
            } else {
                V = "&#26242;&#26080;&#25253;&#20215;"
            }
            $("#price").html(V);
            $("#currentWareId").val(W.ware.wareId)
        }
    }
    function J(U) {
        if (U) {
            $("#stockTip").empty();
            $("#provincetip").empty();
            $("#provincetip").append('<span></span><select class="new-select" id="province" onchange="changeProvince();"></select>');
            $.each(U.provinceList, 
            function(W, V) {
                if (V.label == U.province.id) {
                    $("#stockTip").append(U.province.name);
                    $("#stockTip").append('<input type="hidden" name="provinceName" id="provinceName" value="$!province.name"/>');
                    $("#provinceName").val(U.province.name);
                    $("#provincetip").append(U.province.name);
                    $("#province").append('<option value="' + V.label + '" selected="selected" >' + V.value + "</option> ");
                    if (V.label == "84") {}
                } else {
                    $("#province").append('<option value="' + V.label + '" >' + V.value + "</option> ")
                }
            });
            if (U.city) {
                $("#citytip").empty();
                $("#citytip").append('<span></span><select class="new-select" id="city" onchange="changeCity();"></select>');
                $.each(U.cityList, 
                function(W, V) {
                    if (V.label == U.city.id) {
                        $("#stockTip").append(">" + U.city.name);
                        $("#citytip").append(U.city.name);
                        $("#city").append('<option value="' + V.label + '" selected="selected" >' + V.value + "</option> ")
                    } else {
                        $("#city").append('<option value="' + V.label + '" >' + V.value + "</option> ")
                    }
                })
            }
            if (U.country) {
                $("#countrytip").empty();
                $("#countrytip").append('<span></span><select class="new-select" id="country" onchange="changeCountry();"></select>');
                $.each(U.countryList, 
                function(W, V) {
                    if (V.label == U.country.id) {
                        $("#stockTip").append(">" + U.country.name);
                        $("#countrytip").append(U.country.name);
                        $("#country").append('<option value="' + V.label + '" selected="selected" >' + V.value + "</option> ")
                    } else {
                        $("#country").append('<option value="' + V.label + '" >' + V.value + "</option> ")
                    }
                })
            }
            if (U.town) {
                $("#town_1").empty();
                $("#town_1").append('<span class="select-box new-mg-b10" id="towntip"><span></span><select class="new-select" id="town" onchange="changeTown();"></select></span>');
                $.each(U.townList, 
                function(W, V) {
                    if (V.label == U.town.id) {
                        $("#stockTip").append(">" + U.town.name);
                        $("#towntip").append(U.town.name);
                        $("#town").append('<option value="' + V.label + '" selected="selected" >' + V.value + "</option> ")
                    } else {
                        $("#town").append('<option value="' + V.label + '" >' + V.value + "</option> ")
                    }
                })
            } else {
                $("#towntip").hide()
            }
            if (U.stock && U.stock.status) {
                $("#stockStatus").html('<font color="#c00">' + U.stock.status + "</font>");
                $("#stockStatus_1").html(U.stock.status)
            }
        } else {
            $("#store").hide()
        }
        if (U && U.canBuy && U.stock && U.stock.flag) {
            if ((U.stock.jdPrice > 0) || (U.ware.jdprice > 0)) {
                if ($("#teamSign").val() != 1) {
                    $("#add_cart").removeClass("btn-cart-def");
                    $("#add_cart").unbind("click");
                    $("#add_cart").click(Q)
                }
                $("#stockFlag").val(U.stock.flag);
                $("#directorder").removeClass("btn-buy-def");
                $("#directorder").unbind("click");
                $("#directorder").click(M)
            }
        } else {
            if ($("#teamSign").val() != 1) {
                $("#add_cart").addClass("btn-cart-def");
                $("#add_cart").unbind("click")
            }
            if (U.stock && U.stock.flag) {
                $("#stockFlag").val(U.stock.flag)
            } else {
                $("#stockFlag").val(false);
                $("#add_cart").addClass("btn-cart-def")
            }
            $("#directorder").addClass("btn-buy-def");
            $("#directorder").unbind("click")
        }
    }
	
    var r = $("#currentWareId").val();
    var t = $("#sid").val();
    var q = createSpinner();
    var f = null;
    function R() {
        var U = parseInt(document.body.clientWidth);
        $("#spinnerCache").css("margin-left", (U / 2 - 50) + "px");
        $("#spinnerCache").show();
        q.spin($("#spinnerCache")[0])
    }
    function P() {
        q.stop();
        $("#spinnerCache").hide()
    }
    function u() {
        var U = $.trim($("#imgs").val());
        if (U.substring(U.length - 1) == ",") {
            U = U.substring(0, U.length - 1)
        }
        return U
    }
    var G = new Array(u().split(",").length);
    var k = 0;
    var c = 1;
    function L(W, X, U) {
        var V = new Image();
        V.src = W;
        V.width = X;
        V.height = U;
        V.ontouchstart = h;
        V.ontouchmove = y;
        V.ontouchend = I;
        return V
    }
    $(function() {
        E()
    });
    function E() {
        var X = u();
        if (X != "") {
            var W = X.split(",");
            if (!G[k]) {
                G[k] = (L(W[k], 200, 200))
            }
            var V;
            for (var U = 0; U < c; U++) {
                V = k + (U + 1);
                if (V < W.length) {
                    if (!G[V]) {
                        G[V] = (L(W[V], 200, 200))
                    }
                } else {
                    V = V - W.length;
                    if (!G[V]) {
                        G[V] = (L(W[V], 200, 200))
                    }
                }
                V = k - (U + 1);
                if (V < 0) {
                    V = W.length + V;
                    if (!G[V]) {
                        G[V] = (L(W[V], 200, 200))
                    }
                } else {
                    if (!G[V]) {
                        G[V] = (L(W[V], 200, 200))
                    }
                }
            }
        }
    }
    function e() {
        var V = u();
        k++;
        var U = V.split(",");
        if (k > U.length - 1) {
            k = 0
        }
        E();
        B(G[k], 1)
    }
    function N() {
        var V = u();
        k--;
        var U = V.split(",");
        if (k < 0) {
            k = U.length - 1
        }
        E();
        B(G[k], 0)
    }
    var z,
    w,
    m,
    l,
    b,
    a;
    function h(U) {
        var V = U.touches[0];
        z = V.pageX;
        w = V.pageY
    }
    function y(U) {
        var V = U.touches[0];
        m = V.pageX;
        l = V.pageY;
        b = Math.abs(z - m);
        a = Math.abs(w - l);
        if (b > a) {
            U.preventDefault()
        }
    }
    function I(U) {
        if (b > a) {
            if (z > m) {
                e()
            } else {
                N()
            }
        }
        z = 0,
        w = 0,
        m = 0,
        l = 0,
        b = 0,
        a = 0
    }
    if (document.getElementById("imgSlider")) {
        g(document.getElementById("imgSlider"))
    }
    if (document.getElementById("popImg")) {
        g(document.getElementById("popImg"))
    }
    function O() {
        if ($("#_mask")) {
            $("#_mask").remove()
        }
        var U = ((document.body || document.documentElement).clientHeight + 20) + "px";
        var W = "100%";
        var V = document.createElement("div");
        V.setAttribute("id", "_mask");
        V.setAttribute("style", "position:absolute;left:0px;top:0px;background-color:rgb(0, 0, 0);filter:alpha(opacity=90);opacity: 0.9;width:" + W + ";height:" + U + ";z-index:10001;"); (document.body || document.documentElement).appendChild(V);
        $("#_mask").click(function() {
            $("#cart").hide();
            if ($("#popImg")) {
                $("#popImg").hide()
            }
            if ($("#_mask")) {
                $("#_mask").hide()
            }
        });
        var Y = 400;
        var X = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
        var Z = document.documentElement.clientHeight || document.body.clientHeight;
        document.getElementById("popImg").style.top = ((Z - Y) / 2 + X) + "px";
        $("#popImg").show()
    }
    $("#_zoom").click(function() {
        O()
    })
});
function hidePop() {
    if ($("#_mask")) {
        $("#_mask").remove()
    }
    $("#popImg").hide()
}
function zoomImgLeft() {
    var a = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;
    var c = document.documentElement.clientWidth || document.body.clientWidth;
    var b = a - 150 + (c / 2);
    document.getElementById("popImg").style.left = b + "px"
}

function getLeft() {
	var a = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;
	var d = document.documentElement.clientWidth || document.body.clientWidth;
	var c = a - 114 + (d / 2);
	var b = a - 135 + (d / 2);
	document.getElementById("cart").style.left = c + "px";
	document.getElementById("tip").style.left = b + "px"
}
$(function() {
	getLeft();
	zoomImgLeft();
	$(window).bind("resize",
	function() {
		getLeft();
		zoomImgLeft()
	})
});

var assessPageNo = 1;
function assessRender(c) {
    var b = $('#btnAssess').data('goods_id');
    var d = 0;
    if ($("#_tabGoodScale").hasClass("on")) {
        d = 1
    } else {
        if ($("#_tabMediumScale").hasClass("on")) {
            d = 2
        } else {
            if ($("#_tabBadScale").hasClass("on")) {
                d = 3
            }
        }
    }
    if (!c) {
        $("#_assessScale").html(0);
        $("#_goodScale").html("(0%)");
        $("#_mediumScale").html("(0%)");
        $("#_badScale").html("(0%)");
        $("#_goodScaleImg").css("width", "0%");
        $("#_mediumScaleImg").css("width", "0%");
        $("#_badScaleImg").css("width", "0%");
        $("#goodNum").html(0);
        $("#mediumNum").html(0);
        $("#badNum").html(0)
    }
    $("#_assessPage").html("");
    jQuery.getJSON("index.php?act=goods&op=comments", {
        goods_id: b,
        evalscore: (d > 0 ? d: ""),
        curpage: assessPageNo
    },
    function(x) {
        $("#_assessItem").html('<div class="new-cp-prom2"><span class="new-logo2"></span><strong class="new-span-block">抱歉暂时没有相关结果</strong></div>');
        var e = $('#btnAssess').data('goods_id');
        if (!x.state) {
            return
        }
		
        var m = x.commentCount;
        if (m == 0 && x.comments.length != 0) {
            m = x.comments.length
        }
        if (x.commentCountMap) {
            var r = x.commentCountMap.scoreCount1;
            var n = x.commentCountMap.scoreCount2;
            var p = x.commentCountMap.scoreCount3;
            var j = r + n + p;
            if (r > 0) {
                $("#goodNum").html(r)
            }
            if (n > 0) {
                $("#mediumNum").html(n)
            }
            if (p > 0) {
                $("#badNum").html(p)
            }
            if (j > 0) {
                var u = Math.round(r / j * 100);
                var o = Math.round(n / j * 100);
                var s = Math.round(p / j * 100);
                $("#_assessScale").html(u);
                $("#_goodScale").html("(" + u + "%)");
                $("#_mediumScale").html("(" + o + "%)");
                $("#_badScale").html("(" + s + "%)");
                $("#_goodScaleImg").css("width", u + "%");
                $("#_mediumScaleImg").css("width", o + "%");
                $("#_badScaleImg").css("width", s + "%")
            }
        }
        if (x.comments && x.comments.length > 0) {
            var q = "";
            for (var v = 0, w = x.comments.length; v < w; v++) {
                var f = x.comments[v];
                var g = f.member_name || "";
                if (g.length > 10) {
                    g = f.member_name.substring(0, 10) + "..."
                }
                q = q + '<div class="new-gd-introduce"><div class="new-mg-t10"><span class="new-gd-txt2"><span class="new-fl">美财口碑：</span><span class="new-gd-txt3">' + f.geval_content + '</span></span></div><div class="new-p-re new-mg-t10"><span class="new-mu-star"><span class="new-mu-starv" style="width:' + (parseInt(f.geval_scoressign) + Math.random()*10) + '%"></span></span><span class="new-gd-user">' + g + " " + (f.geval_addtime.length > 10 ? f.geval_addtime.substring(0, 10) : f.geval_addtime) + "</span></div></div>"
            }
            $("#_assessItem").html(q)
        } else {
            $("#_assessItem").html('<div class="new-cp-prom2"><span class="new-logo2"></span><strong class="new-span-block">抱歉暂时没有相关结果</strong></div>')
        }
        var h = x.totalPage || 0;
        if (h > 100) {
            h = 100
        }
        var t = assessPageNo;
        if (h > 0) {
            var q = '<div class="new-tbl-type"><div class="new-tbl-cell">' + (assessPageNo != 1 ? '<a href="javascript:prevAssess()" class="new-a-prve"><span>&#19978;&#19968;&#39029;</span></a>': '<span class="new-a-prve"><span>&#19978;&#19968;&#39029;</span></span>') + '</div><div class="new-tbl-cell new-p-re"><div class="new-a-page"><span class="new-open">' + assessPageNo + "/" + h + '</span></div><select class="new-select" id="_assessSelectNo" onchange = "goSelectPage()">';
            for (var v = 0; v < h; v++) {
                q += '<option value="' + (v + 1) + '" ' + (v + 1 == t ? "selected": "") + ">&#31532;" + (v + 1) + "&#39029;</option>"
            }
            q = q + '</select></div><div class="new-tbl-cell">' + (t != h ? '<a href="javascript:nextAssess()" class="new-a-next"><span>&#19979;&#19968;&#39029;</span></a>': '<span class="new-a-next"><span>&#19979;&#19968;&#39029;</span></span>') + "</div></div>";
            $("#_assessPage").html(q)
        } else {
            $("#_assessPage").html("")
        }
    })
}
$(function() {
	$("#btnAssess").click(function() {
		assessPageNo = 1;
		assessRender(false)
	})
});
function nextAssess() {
	assessPageNo++;
	assessRender(true)
}
function prevAssess() {
	assessPageNo--;
	assessRender(true)
}
function goSelectPage() {
	assessPageNo = $("#_assessSelectNo").val();
	assessRender(true)
}
function changeAssessType(a) {
	var b = a.id;
	if (b != "_tabGoodScale") {
		$("#_tabGoodScale").removeClass("on")
	}
	if (b != "_tabMediumScale") {
		$("#_tabMediumScale").removeClass("on")
	}
	if (b != "_tabBadScale") {
		$("#_tabBadScale").removeClass("on")
	}
	if ($(a).hasClass("on")) {
		$(a).removeClass("on")
	} else {
		$(a).addClass("on")
	}
	assessPageNo = 1;
	assessRender(true)
};

var cosultingPageNo = 1;
function cosultingRender() {
    var goods_id = $('#consultations').data('goods_id');
	$("#cosult").html('<div class="new-cp-prom2"><span class="new-logo2"></span><strong class="new-span-block">抱歉暂时没有相关结果</strong></div>')
    jQuery.getJSON("index.php?act=goods&op=cosulting", {
        goods_id: goods_id,
        curpage: cosultingPageNo
    },
    function(data) {
        var goods_id = $('#consultations').data('goods_id');
        if (!data.state) {
            return
        }
        if (data.consult_list && data.consult_list.length > 0) {
            var q = "";
            for (var v = 0, w = data.consult_list.length; v < w; v++) {
                var f = data.consult_list[v];
                var g = f.cmember_name || "";
                if (g.length > 10) {
                    g = f.cmember_name.substring(0, 10) + "..."
                }
                q += '<ul><li class="q"><span class="ico"></span>'+f.consult_content+'<br/><span class="gray">'+g+'</span><span class=" gray fr">'+f.consult_addtime+'</span></li>'+((f.consult_reply != '' && f.consult_reply != null) ? '<li class="last a"><span></span>'+f.consult_reply+'</li>' : '')+'</ul>';
            }
            $("#cosult").html(q)
        } else {
            $("#cosult").html('<div class="new-cp-prom2"><span class="new-logo2"></span><strong class="new-span-block">抱歉暂时没有相关结果</strong></div>')
        }
        var h = data.totalPage || 0;
        if (h > 100) {
            h = 100
        }
        var t = cosultingPageNo;
        if (h > 0) {
            var q = '<div class="new-tbl-type"><div class="new-tbl-cell">' + (cosultingPageNo != 1 ? '<a href="javascript:prevcosulting()" class="new-a-prve"><span>&#19978;&#19968;&#39029;</span></a>': '<span class="new-a-prve"><span>&#19978;&#19968;&#39029;</span></span>') + '</div><div class="new-tbl-cell new-p-re"><div class="new-a-page"><span class="new-open">' + cosultingPageNo + "/" + h + '</span></div><select class="new-select" id="_cosultingSelectNo" onchange = "goSelectPage()">';
            for (var v = 0; v < h; v++) {
                q += '<option value="' + (v + 1) + '" ' + (v + 1 == t ? "selected": "") + ">&#31532;" + (v + 1) + "&#39029;</option>"
            }
            q = q + '</select></div><div class="new-tbl-cell">' + (t != h ? '<a href="javascript:nextcosulting()" class="new-a-next"><span>&#19979;&#19968;&#39029;</span></a>': '<span class="new-a-next"><span>&#19979;&#19968;&#39029;</span></span>') + "</div></div>";
            $("#_cosultingPage").html(q)
        } else {
            $("#_cosultingPage").html("")
        }
    })
}
$(function() {
	$("#consultations").click(function() {
		cosultingPageNo = 1;
		cosultingRender()
	})
});
function nextcosulting() {
	cosultingPageNo++;
	cosultingRender()
}
function prevcosulting() {
	cosultingPageNo--;
	cosultingRender()
}
function goSelectPage() {
	cosultingPageNo = $("#_cosultingSelectNo").val();
	cosultingRender()
}